﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace HHWeb.Handler
{
    /// <summary>
    /// CheckUserCode 的摘要说明
    /// </summary>
    public class CheckUserCode : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string UserCode = context.Request.Form["UserCode"].ToString();
            string UserNumber = context.Request.Form["UserNumber"].ToString();
            string Command = context.Request.Form["Command"].ToString();
            context.Response.Write(GetBoolByUserCodeAndUserNumber(Command,UserCode, UserNumber));
        }
        HHBLL.Users B = new HHBLL.Users();
        public int GetBoolByUserCodeAndUserNumber(string Command,string UserCode, string UserNumber)
        {
            if (Command == "Add")
            {
                if (B.Exists(UserCode))
                    return 1;//存在
                else
                    return 0;//不存在
            }
            if (B.ExistsUserCode(UserNumber,UserCode))
                return 1;//存在
            else
                return 0;//不存在
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}